const CloudDBZoneWrapper = require('./CloudDBZoneWrapper')

let myHandler = async function (event, context, callback, logger) {
  //把参数信息注册到后台
  logger.info(event);

  // do something here
  //初始化云数据库实例，并拿到相关的操作方法
  const cloudDBZoneWrapper = new CloudDBZoneWrapper(logger)

  //const data = await cloudDBZoneWrapper.queryAll()

  //const data = event.body

const {payload,action} = JSON.parse(event.body)

  if (action === 'add') {
    await CloudDBZoneWrapper.add(payload)
    return callback({
      code:0,
      status:true
    })
  }
  /*
   * 给前端返回数据的方法
   * */
  /*callback({
    code: 0,
    desc: "Success.",
    data
  });*/
};

export { myHandler };